# Maintainer: Maxime Gauduin <alucryd@archlinux.org>

pkgname=libretro-citra
pkgver=9304
pkgrel=1
pkgdesc='Nintendo 3DS core'
arch=(loong64 x86_64)
url=https://github.com/libretro/citra
license=(GPL2)
groups=(libretro)
depends=(
  libretro-core-info
  sdl2
)
makedepends=(
  git
  nasm
)
_commit=d7e1612c17b1acb5d5eb68bb046820db49aeea5e
source=(
  libretro-citra::git+https://github.com/libretro/citra.git#commit=${_commit}
  citra-boost::git+https://github.com/citra-emu/ext-boost.git
  catch::git+https://github.com/philsquared/Catch.git
  git+https://github.com/arun11299/cpp-jwt.git
  git+https://github.com/kinetiknz/cubeb.git
  git+https://github.com/discordapp/discord-rpc.git
  git+https://github.com/weidai11/cryptopp.git
  git+https://github.com/MerryMage/dynarmic.git
  git+https://github.com/lsalzman/enet.git
  ffmpeg::git+https://github.com/FFmpeg/FFmpeg.git
  git+https://github.com/fmtlib/fmt.git
  git+https://github.com/benhoyt/inih.git
  citra-libressl::git+https://github.com/citra-emu/ext-libressl-portable.git
  git+https://github.com/libusb/libusb.git
  git+https://github.com/lemenkov/libyuv.git
  git+https://github.com/lvandeve/lodepng.git
  git+https://github.com/neobrain/nihstro.git
  citra-soundtouch::git+https://github.com/citra-emu/ext-soundtouch.git
  git+https://github.com/wwylele/teakra.git
  git+https://github.com/herumi/xbyak.git
  git+https://github.com/facebook/zstd.git
)
b2sums=('SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP'
        'SKIP')

prepare() {
  cd libretro-citra
  for submodule in externals/{catch,cpp-jwt,cryptopp/cryptopp,cubeb,discord-rpc,dynarmic,enet,ffmpeg,fmt,inih/inih,libressl,libusb/libusb,libyuv,lodepng/lodepng,nihstro,teakra,xbyak,zstd}; do
    git submodule init ${submodule}
    git config submodule.${submodule}.url ../${submodule##*/}
    git -c protocol.file.allow=always submodule update ${submodule}
  done
  for submodule in externals/{boost,soundtouch}; do
    git submodule init ${submodule}
    git config submodule.${submodule}.url ../citra-${submodule##*/}
    git -c protocol.file.allow=always submodule update ${submodule}
  done

# Fix build with glibc 2.34
  find -name catch.hpp | xargs sed -e 's|MINSIGSTKSZ|2048|g' -i
}

pkgver() {
  cd libretro-citra
  git rev-list --count HEAD
}

build() {
  cd libretro-citra
  make
}

package() {
  install -Dm 644 libretro-citra/citra_libretro.so -t "${pkgdir}"/usr/lib/libretro/
}

# vim: ts=2 sw=2 et:
